﻿@model System.DateTime

<span class="weibo-date">
@{
    
    var now = DateTime.UtcNow;
    var postTime = Model.ToUniversalTime();
    var span = now.Subtract(postTime);
    var east8Time = postTime.AddHours(8);
    if(span.TotalDays < 1.0)
    {
        if (now.AddHours(8).Day != east8Time.Day)
        {
            @Html.Raw(string.Format("{0} yday", east8Time.ToShortTimeString()));
        }
        else if(span.TotalHours > 1)
        {
            @Html.Raw(string.Format("{0}", east8Time.ToShortTimeString()));
        }
        else if(span.TotalMinutes > 0.5)
        {
            @Html.Raw(string.Format("{0} min{1} ago", span.TotalMinutes.ToString("0"), span.TotalMinutes > 1 ? "s" : ""));
        }
        else
        {
            @Html.Raw("seconds ago");
        }
    }
    else
    {
        @Html.Raw(string.Format(east8Time.ToString("h:mm M/d")));
    }    
}
</span>